package com.atguigu.tingshu.user.api;

import com.atguigu.tingshu.common.result.Result;
import com.atguigu.tingshu.model.user.UserInfo;
import com.atguigu.tingshu.user.service.UserInfoService;
import com.atguigu.tingshu.vo.user.UserInfoVo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@Tag(name = "用户管理接口")
@RestController
@RequestMapping("api/user")
@SuppressWarnings({"all"})
public class UserInfoApiController {

	@Autowired
	private UserInfoService userInfoService;


	/**
	 * 根据用户ID查询用户信息
	 * @param userId
	 * @return
	 */
	@Operation(summary = "根据用户ID查询用户信息")
	@GetMapping("/userInfo/getUserInfoVo/{userId}")
	public Result<UserInfoVo> getUserInfoVo(@PathVariable Long userId){

		return Result.ok(userInfoService.getUserInfoVoById(userId));
	}

	/**
	 * 该接口提供给专辑服务，展示声音列表动态判断付费标识
	 * 判断当前用户某一页中声音列表购买情况
	 * @param userId
	 * @param albumId
	 * @param needChackTrackIdList 待检查购买情况当前专辑声音列表
	 * @return data:{声音ID:购买结果} 结果:1(已购) 0(未购买)
	 */
	@Operation(summary = "获取用户声音列表付费情况")
	@PostMapping("/userInfo/userIsPaidTrack/{userId}/{albumId}")
	public Result<Map<Long,Integer>> userIsPaidTrack(@PathVariable Long userId, @PathVariable Long albumId,
													 @RequestBody List<Long> needChackTrackIdList){
		Map<Long,Integer> mapResult = userInfoService.userIsPaidTrack(userId,albumId,needChackTrackIdList);
		return Result.ok(mapResult);
	}

}

